package com.itheima.mymap;

import java.util.*;
import java.util.stream.Stream;

/*
aababcabcdabcde在控制台输出: “a(5)b(4)c(3)d(2)e(1)”
 */
public class Dmeo4 {
    public static void main(String[] args) {
        //定义字符串
        String s = "aababcabcdabcde";
        //定义集合
        TreeMap<Character,Integer> tm = new TreeMap<>();
        //遍历字符串
        for (int i = 0; i <s.length() ; i++) {
            //得到每一个字符
            char c = s.charAt(i);
            //判断
            if(!tm.containsKey(c)){
                tm.put(c,1);
            }else{
                //因为之前就已经将值存储进去了,所以当第二次出现时可以通过键把值取出加一
                Integer count = tm.get(c);
                count++;
                tm.put(c,count);
            }
        }
        //遍历数组
        Set<Character> characters = tm.keySet();
        for (Character character : characters) {
            Integer integer = tm.get(character);
            System.out.print(character+"("+integer+")");
        }

        //流的获取,同类型不同数据
        Stream<Integer> integerStream = Stream.of(12, 13, 14, 15, 16);
        //数组获取流
        String[] str = {"wd","d","sk"};
        Stream<String> stream = Arrays.stream(str);
        //list,set集合获取流
        ArrayList<String> arr = new ArrayList<>(List.of("s","dsh","ds","fhs"));
        Stream<String> stream1 = arr.stream();

        Set<String> set = new TreeSet<>(List.of("dis","hiw","hs"));
        Stream<String> stream2 = set.stream();
        Stream<String> stringStream = stream2.filter(ss -> ss.length() == 3);



    }
}
